package org.xserver.component.core;

import javax.annotation.Resource;
import javax.net.ssl.SSLEngine;

import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.handler.ssl.SslHandler;
import org.springframework.stereotype.Component;

/**
 * The Https factory extends Http factory just add first {@link SslHandler} to
 * support https prototype.
 *
 * @author idoldefine
 * @since 2013/01/10
 */
@Component
public class XServerHttpsFactory extends XServerHttpFactory {
	@Resource
	private XServerHttpSSLEngineFactory xServerHttpSSLEngineFactory;

	@Override
	public ChannelPipeline getPipeline() throws Exception {
		ChannelPipeline pipeline = super.getPipeline();

		SSLEngine sslEngine = xServerHttpSSLEngineFactory.getInstance();

		pipeline.addFirst(SslHandler.class.getSimpleName(), new SslHandler(
				sslEngine));

		return pipeline;
	}
}
